package com.alibaba.demo.service.assembler;

import com.alibaba.demo.domain.service.entity.IotServiceEntity;
import com.alibaba.demo.dto.clientobject.service.IotServiceCO;
import com.alibaba.demo.dto.command.IotServiceAddCmd;
import org.mapstruct.*;

/**
 * @author Administrator
 * @date 2024/4/28 10:14
 * @description
 */
@Mapper(componentModel = "spring",nullValueCheckStrategy = NullValueCheckStrategy.ALWAYS,
        nullValuePropertyMappingStrategy = NullValuePropertyMappingStrategy.IGNORE)
public interface IotServiceAssembler {

    IotServiceEntity toEntity(IotServiceAddCmd cmd);

//    @Mappings({
//            @Mapping(source = "id", target = "id", ignore = true)
//    })
    IotServiceCO toCo(IotServiceEntity saveResult);

//    public static IotServiceEntity toEntity(IotServiceAddCmd cmd) {
//        IotServiceEntity iotServiceEntity = new IotServiceEntity();
//        iotServiceEntity.setMqttUser(cmd.getMqttUser());
//        iotServiceEntity.setMqttServiceName(cmd.getMqttServiceName());
//        iotServiceEntity.setType(cmd.getType());
//        iotServiceEntity.setMqttDomain(cmd.getMqttDomain());
//        iotServiceEntity.setMqttPort(cmd.getMqttPort());
//        iotServiceEntity.setMqttPwd(cmd.getMqttPwd());
//        iotServiceEntity.setPlatformUrl(cmd.getPlatformUrl());
//        return iotServiceEntity;
//    }
//
//    public static IotServiceCO toCo(IotServiceEntity saveResult) {
//        IotServiceCO iotServiceCO = new IotServiceCO();
//        iotServiceCO.setId(saveResult.getId());
//        iotServiceCO.setMqttUser(saveResult.getMqttUser());
//        iotServiceCO.setMqttServiceName(saveResult.getMqttServiceName());
//        iotServiceCO.setType(saveResult.getType());
//        iotServiceCO.setMqttDomain(saveResult.getMqttDomain());
//        iotServiceCO.setMqttPort(saveResult.getMqttPort());
//        iotServiceCO.setMqttPwd(saveResult.getMqttPwd());
//        iotServiceCO.setPlatformUrl(saveResult.getPlatformUrl());
//        return iotServiceCO;
//    }

}
